var LANG = {
	current: 'en',
	current_text: 'English',
	init : function() {
		$('.language').langSelector({
			langs : [{
						text : 'Tiếng Việt',
						value : 'vi',
						img_path: '/css/jquery/language/vi.png'
					}, {
						text : 'English',
						value : 'en',
						img_path: '/css/jquery/language/en.png'
					}],
			def : {
				text : LANG.current_text,
				value : LANG.current,
				img: true
			},
			callback : function(val) {
				var location = window.location.toString();
				var languages = ['en','vi','ja'];
				var is_correct = false;
				for(i=0;i<languages.length;i++){
					if(val.toLowerCase()==languages[i].toLowerCase()){
						is_correct = true;
						break;
					}
				}
				if(is_correct){
					for(i=0;i<languages.length;i++){
						if(val!=languages[i]){
							if(location.indexOf('/admin/'+languages[i]+'/')>=0){
								window.location = (location.replace('/admin/'+languages[i]+'/', '/admin/'+val+'/'));
								return false;
							}
						}
					}
					if(location.indexOf('/admin/'+val)<0){
						window.location = (location.replace('/admin/', '/admin/'+val+'/'));
					}
				}
				return false;
			},
		});
	},
	
};